//
//  TL_FeedbackTextViewTableViewCell.m
//  WXReader
//
//  Created by Andrew on 2019/12/27.
//  Copyright © 2019 Andrew. All rights reserved.
//

#import "TL_FeedbackTextViewTableViewCell.h"
#import "TL_TextView.h"

@interface TL_FeedbackTextViewTableViewCell () <TL_TextViewDelegate> {
    TL_TextView *textView;
}

@end

@implementation TL_FeedbackTextViewTableViewCell

- (void)createSubviews {
    UIView *backView = [TL_UIFactory view];
    backView.backgroundColor = [UIColor whiteColor];
    backView.layer.cornerRadius = 6;
    [self.contentView addSubview:backView];

    [backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.mas_equalTo(0);
        make.left.mas_equalTo(kMoreHalfMargin);
        make.right.mas_equalTo(-kMoreHalfMargin);
        make.height.mas_equalTo(156);
    }];
    
    textView = [[TL_TextView alloc] initWithFrame:CGRectZero];
    textView.maxWordCount = 500;
    textView.delegate = self;
    textView.layer.borderWidth = CGFLOAT_MIN;
    textView.layer.cornerRadius = 4;
    textView.backgroundColor = UIColor.whiteColor;
    [textView resetPlaceholderText:@"Describe your issues (required)"];
    [self.contentView addSubview:textView];
    
    [textView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(backView).offset(kQuarterMargin);
        make.top.bottom.mas_equalTo(0);
        make.right.mas_equalTo(backView).offset(-kQuarterMargin);
    }];
}

- (void)textViewDidChange:(NSString *)text {
    if (self.textViewDidChange) {
        self.textViewDidChange(text);
    }
}

@end
